﻿#region File Description

//-----------------------------------------------------------------------------
// IService.cs
//
// Author: ITU Team3 (2012)
//-----------------------------------------------------------------------------

#endregion File Description

#region Using Statements

using System.ServiceModel;

#endregion Using Statements

namespace rentit03_server
{
    [ServiceContract]
    public interface IService
    {
        #region Test

        /// <summary>
        /// Test Method
        /// </summary>
        /// <returns>Returns "Hello World!" as a string</returns>
        [OperationContract]
        string HelloWorld();

        #endregion Test

        #region Login/Logout

        /// <summary>
        /// Login to the system and obtain a session id.
        /// </summary>
        /// <param name="username">A username for an account</param>
        /// <param name="password">The matching password</param>
        /// <returns>JSON return object. If the username and password are valid, the value of the return object is a new session id</returns>
        [OperationContract]
        string Login(string username, string password);

        /// <summary>
        /// Terminate a current session. After calling this method the session id will no longer be valid.
        /// </summary>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object stating if the logout operation wass successful.</returns>
        [OperationContract]
        string Logout(string sessionId);

        #endregion Login/Logout

        #region User

        /// <summary>
        /// Create a new user
        /// </summary>
        /// <param name="userObj">JSON user object</param>
        /// <param name="sessionId">Session id - may be an empty string for anonymous users</param>
        /// <returns>JSON return object. If the user was created successfully, the value of the return object is the id of the new user.</returns>
        [OperationContract]
        string CreateUser(string userObj, string sessionId = "");

        /// <summary>
        /// Read a user from a current session
        /// </summary>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. If a user was read succesfully, the value of the return object will be a user object.</returns>
        [OperationContract]
        string ReadUserFromSession(string sessionId);

        /// <summary>
        /// Read a user from a user id
        /// </summary>
        /// <param name="userId">Id of the user you want to read</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. If a user was read succesfully, the value of the return object will be a user object.</returns>
        [OperationContract]
        string ReadUser(int userId, string sessionId = "");

        /// <summary>
        /// Edit a user by providing a JSON user object.
        /// The user will be overridden with the JSON user object.
        /// Only fields contained in the user object will be touched.
        /// </summary>
        /// <param name="userId">Id of the user you want to edit</param>
        /// <param name="userObj">JSON user object</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object stating if the user was edited successfully.</returns>
        [OperationContract]
        string EditUser(int userId, string userObj, string sessionId);

        /// <summary>
        /// Delete a user
        /// </summary>
        /// <param name="userId">Id of the user you wnat to delete</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object stating if the user was deleted succesfully</returns>
        [OperationContract]
        string DeleteUser(int userId, string sessionId);

        [OperationContract]
        string OverviewUserCount(string userSearchParems, string sessionId = "");

        /// <summary>
        /// Get an overview of users.
        /// This is used for searching.
        /// </summary>
        /// <param name="userSearchParem">JSON user search parameters</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. The value of the return object will be a list of user objects.</returns>
        [OperationContract]
        string OverviewUsers(string userSearchParem, string sessionId = "");

        #endregion User

        #region Credits

        /// <summary>
        /// Get the amount of credits (balance) for a given user.
        /// </summary>
        /// <param name="userId">Id of the user you want to read amount of credits from</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object where value in a successful call is the amount of credits the given user has</returns>
        [OperationContract]
        string ReadCredits(int userId, string sessionId);

        /// <summary>
        /// Edit the amount of credits (balance) for a given user.
        /// </summary>
        /// <param name="userId">Id of the user you want to edit</param>
        /// <param name="amount">Amount you want to add to the balance of the given user.
        /// This amount can be negative in case you want to subtract the amount.</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object describing if the operation was successful or not.</returns>
        [OperationContract]
        string EditCredits(int userId, int amount, string sessionId);

        #endregion Credits

        #region Media

        /// <summary>
        /// Create new media
        /// </summary>
        /// <param name="mediaObj">JSON media object</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. If the media was created successfully, the value of the return object is the id of the new media.</returns>
        [OperationContract]
        string CreateMedia(string mediaObj, string sessionId);

        /// <summary>
        /// Read media
        /// </summary>
        /// <param name="mediaId">Id of media you want to read</param>
        /// <param name="sessionId">Session id - may be an empty string for anonymous users</param>
        /// <returns>JSON return object. If a media was read succesfully, the value of the return object will be a media object.</returns>
        [OperationContract]
        string ReadMedia(int mediaId, string sessionId = "");

        /// <summary>
        /// Read media from a version id.
        /// Every media can have several versions (eg. high definition and standard definition).
        /// When you have a version id in your shopping cart,
        /// use this method to get the corresponding media.
        /// </summary>
        /// <param name="versionId">Version id</param>
        /// <param name="sessionId">Session id - may be an empty string for anonymous users</param>
        /// <returns>JSON return object. If the media was read succesfully, the value of the return object is a media object.</returns>
        [OperationContract]
        string ReadMediaFromVersionId(int versionId, string sessionId = "");

        /// <summary>
        /// Edit media by providing a JSON media object.
        /// The media will be overridden with the JSON media object.
        /// Only fields contained in the media object will be touched.
        /// </summary>
        /// <param name="mediaId">Id of media you want to edit</param>
        /// <param name="mediaObj">JSON media object</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object stating if the media was edited successfully.</returns>
        [OperationContract]
        string EditMedia(int mediaId, string mediaObj, string sessionId);

        /// <summary>
        /// Delete media
        /// </summary>
        /// <param name="mediaId">Id of media you want to delete</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object stating if the media was successfully deleted.</returns>
        [OperationContract]
        string DeleteMedia(int mediaId, string sessionId);

        [OperationContract]
        string OverviewMediaCount(string mediaSearchParems, string sessionId = "");

        /// <summary>
        /// Get a overview of medias.
        /// This is used for searhing.
        /// </summary>
        /// <param name="mediaSearchParems">JSON media search parameters</param>
        /// <param name="sessionId">Session id - may be an empty string for anonymous users</param>
        /// <returns>JSON return object. The value of the return object will be a list of media objects.</returns>
        [OperationContract]
        string OverviewMedia(string mediaSearchParems, string sessionId = "");

        /// <summary>
        /// List all versions for a given media.
        /// Use this when listing the different version of a media.
        /// When a user purchases a media, they will actually purchase a specific version of that media.
        /// </summary>
        /// <param name="mediaId">Media id</param>
        /// <param name="sessionId">Session id - may be an empty string for anonymous users</param>
        /// <returns>JSON return object. The value of the return object will be a list of versions.</returns>
        [OperationContract]
        string OverviewVersions(int mediaId, string sessionId = "");

        /// <summary>
        /// Get a list of all genres in the system.
        /// </summary>
        /// <param name="sessionId">Session Id</param>
        /// <returns>JSON return object containing a list of all genres</returns>
        [OperationContract]
        string OverviewGenres(string sessionId = "");

        /// <summary>
        /// Get a list od all languages in the system.
        /// </summary>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object containing a list of all languages</returns>
        [OperationContract]
        string OverviewLanguages(string sessionId = "");

        #endregion Media

        #region Comments

        /// <summary>
        /// Create a new comment for a specific media.
        /// </summary>
        /// <param name="commentObj">JSON comment object</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. If the comment was created successfully, the value of the return object is the id of the new comment.</returns>
        [OperationContract]
        string CreateComment(string commentObj, string sessionId);

        /// <summary>
        /// Read a comment by its id.
        /// </summary>
        /// <param name="commentId">Id of the comment you want to read</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. If a comment was read succesfully, the value of the return object will be a comment object.</returns>
        [OperationContract]
        string ReadComment(int commentId, string sessionId);

        /// <summary>
        /// Edit comment by providing a JSON comment object.
        /// The comment will be overridden with the provided object.
        /// </summary>
        /// <param name="commentId">Id of the comment you want to edit</param>
        /// <param name="commentObj">JSON comment object</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. The status of the return object will tell if the comment was edited successfully.</returns>
        [OperationContract]
        string EditComment(int commentId, string commentObj, string sessionId);

        /// <summary>
        /// Delete a comment by providing a comment id.
        /// </summary>
        /// <param name="commentId">Id of the comment you want to delete</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. The status of the object will tell if the comment was successfully deleted.</returns>
        [OperationContract]
        string DeleteComment(int commentId, string sessionId);

        #endregion Comments

        #region Shopping Cart

        /// <summary>
        /// Get shopping cart for current session.
        /// </summary>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. The value of the return object will be a list of the version ids currently in the users cart.</returns>
        [OperationContract]
        string GetCart(string sessionId);

        /// <summary>
        /// Add media to shopping cart.
        /// </summary>
        /// <param name="versionId">Id of the version you want to add</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object stating if the version was successfully added to the users shoppingcart.</returns>
        [OperationContract]
        string AddToCart(int versionId, string sessionId);

        /// <summary>
        /// Remove media from shopping cart.
        /// If you remove an item, but the cart contains several instances of that same item, only one instance will be removed.
        /// </summary>
        /// <param name="versionId">Id of the version you want to remove</param>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object stating if the version was succesfully removed from the cart.</returns>
        [OperationContract]
        string RemoveFromCart(int versionId, string sessionId);

        /// <summary>
        /// Clear (empty) the session shopping cart.
        /// </summary>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object stating if the shoppingcart was successfully cleared</returns>
        [OperationContract]
        string ClearCart(string sessionId);

        /// <summary>
        /// Purchase everything currently in the shopping cart.
        /// Credits will be subtracted from user account.
        /// </summary>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object stating if the operation succeeded</returns>
        [OperationContract]
        string CheckOutCart(string sessionId);

        /// <summary>
        /// A list of all purchases made by the current user.
        /// </summary>
        /// <param name="sessionId">Session id</param>
        /// <returns>JSON return object. The value of the return object will be a list of purchase objects.</returns>
        [OperationContract]
        string OverviewPurchases(string sessionId);

        #endregion Shopping Cart

        #region top

        /// <summary>
        /// A list of the top rated movies from IMDb rating
        /// </summary>
        /// <param name="page">The page number to show movies for</param>
        /// <param name="count">The number of movies shown per page</param>
        /// <param name="sessionId">The session id</param>
        /// <returns>JSON return object. The value of the return object is a list of movies</returns>
        [OperationContract]
        string TopRatedMovies(int page, int count, string sessionId);

        /// <summary>
        /// A list of random movies from the database
        /// </summary>
        /// <param name="count">The number of random movies to fetch</param>
        /// <param name="sessionId">The session id</param>
        /// <returns>JSON return object. The value of the return object is a list of movies</returns>
        [OperationContract]
        string RandomMovies(int count, string sessionId);

        #endregion top

        #region Other

        /// <summary>
        /// Get a human readable string with a list of all return statuses in the service
        /// </summary>
        /// <returns>List of all return statuses</returns>
        [OperationContract]
        string GetReturnStatuses();

        /// <summary>
        /// Get a human readable string with a list of all permissions in the service
        /// </summary>
        /// <returns>List of all permissions</returns>
        [OperationContract]
        string GetPermissions();

        /// <summary>
        /// Create a new user role
        /// </summary>
        /// <param name="roleObj">The role object to create</param>
        /// <param name="sessionId">The session id</param>
        /// <returns>JSON return object stating if the operation succeeded</returns>
        [OperationContract]
        string CreateRole(string roleObj, string sessionId);

        /// <summary>
        /// Read a user role
        /// </summary>
        /// <param name="rId">The id of the role to read</param>
        /// <param name="sessionId">The session id</param>
        /// <returns>JSON return object. The value of the return object is a role</returns>
        [OperationContract]
        string ReadRole(int rId, string sessionId);

        /// <summary>
        /// Create a permission
        /// </summary>
        /// <param name="permission">The permission object to create</param>
        /// <param name="sessionId">The session id</param>
        /// <returns>JSON return object stating if the operation succeeded</returns>
        [OperationContract]
        string CreatePermission(string permission, string sessionId);

        /// <summary>
        /// Populate the database with initial users, roles and permissions and links them together
        /// </summary>
        /// <returns>JSON return object stating if the operation succeeded</returns>
        [OperationContract]
        string PopulateDatabase();

        #endregion Other
    }
}